import {createStore} from 'vuex';
import createPersistedState from "vuex-persistedstate"
import sessionStorage from '@/store/modules/sessionStorage';
import localStorage from '@/store/modules/localStorage';

export default createStore({
    state: {
        test: ''
    },
    mutations: {
        test(state: any, value: any) {state.test = value;},
    },
    actions: {

    },
    modules: {
        sessionStorage, localStorage
    },
    getters: {

    },
    plugins: [
        //持久化vuex
        createPersistedState({
            storage: window.sessionStorage,
            key:'elegantStorage', //Storage的key,默认vuex
            paths: ['sessionStorage'],
        }),
        //持久化vuex
        createPersistedState({
            storage: window.localStorage,
            key:'elegantStorage', //Storage的key,默认vuex
            paths: ['localStorage'],
        }),
    ]
})
